package org.linuxgears.BouncingBall.mover.strategy;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.linuxgears.BouncingBall.model.Point;
import org.linuxgears.BouncingBall.tools.BallTools;

import com.sun.xml.internal.fastinfoset.util.StringArray;

public class LineMovingStrategy implements ProgressiveMovingStrategy {
	private static Log log = LogFactory.getLog(LineMovingStrategy.class);
	
    public static final double DEFAULT_BALL_VELOCITY = 2;
    
	private Point velocity;
	private Point position;

	public LineMovingStrategy() {
		position = new Point(0, 0);
	}

	@Override
	public Point getPosition() {
		return position;
	}

	@Override
	public void move() {
		position.incX(velocity.getX());
		position.incY(velocity.getY());
	}

	@Override
	public void setTargetPoint(Point target) {
		velocity = BallTools.expandVector(position, target, DEFAULT_BALL_VELOCITY);
		log.info("From " + position + " to " + target + " with velocitry: " + velocity);
	}

	@Override
	public Point getVelocity() {
		return velocity;
	}

	@Override
	public void setVelocity(Point velocity) {
		this.velocity = velocity; 
	}

	@Override
	public void setPosition(Point position) {
		this.position = position;
	}

}
